<template>
	<div class="login">
		<div class="login-form">
			
		<el-form :model="ruleForm" status-icon :rules="rules" ref="ruleForm" label-width="100px" class="demo-ruleForm">
		 <div class="title-container">
		   <h3 class="title" style="color: #fff;">考试后台管理系统</h3>
		 </div>
		  <el-form-item label="账号" prop="account">
		    <el-input type="text" v-model="ruleForm.account" autocomplete="off"></el-input>
		  </el-form-item>
		  <el-form-item label="密码" prop="checkPass">
		    <el-input type="password"  v-model="ruleForm.checkPass" autocomplete="off"></el-input>
		  </el-form-item>
		  <div style="padding: 0px 10px 22px 11px">
		    <el-button type="primary" @click="submitForm('ruleForm')">登陆</el-button>
			<el-button @click="resetForm('ruleForm')">重置</el-button>
		  </div>
		</el-form>
		</div>
	</div>
</template>

<script>
	export default {
	    data() {
	      var checkAccount = (rule, value, callback) => {
	        if (value === '') {
	          callback(new Error('请输入账号'));
	        } else {
	          callback();
	        }
	      };
	      var validatePass = (rule, value, callback) => {
	        if (value === '') {
	          callback(new Error('请输入密码'));
	        } else {
	          callback();
	        }
	      };
	      return {
	        ruleForm: {
	          account: '',
	          checkPass: ''
	        },
	        rules: {
	          account: [
	            { validator: checkAccount, trigger: 'blur' }
	          ],
	          checkPass: [
	            { validator: validatePass, trigger: 'blur' }
	          ]
	        }
	      };
	    },
	    methods: {
	      submitForm(formName) {
	        this.$refs[formName].validate((valid) => {
	          if (valid) {
				  
	            alert('submit!');
				this.$router.push('/about');
	          } else {
	            console.log('error submit!!');
	            return false;
	          }
	        });
	      },
	      resetForm(formName) {
	        this.$refs[formName].resetFields();
	      }
	    }
	  }
</script>

<style>
	.login{
		background-color: #283443;
		height: 100%;
		width: 100%;
		display: flex;
		justify-content: center; /* 相对父元素水平居中 */
		align-items: center; /*  子元素相对父元素垂直居中 */
	}
.login-form{
	width: 520px;
	max-width: 100%;
	padding:30px 50px 10px 50px;
	margin:120px auto auto auto;
	overflow: hidden;
	background: rgba(252, 254, 255, 0.11)
}
</style>
